package org.hu.controller;

import org.hu.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 注册审批
 * @author Htrees
 */
@Controller
@RequestMapping("/admin")
public class ApproveaccountController {
    @Autowired
    EmployeeService employeeService;

    /**
     * 跳转到批准用户页面
     */
    @RequestMapping("/approveaccount")
    public String approveaccount(Model model){
        model.addAttribute("emps",employeeService.getEmployeeByStatus(0));
        return "approveaccount";
    }

    /**
     * 审批用户
     * @param employeeid 用户id
     * @param status 状态 0为待批准 1为批准通过 2为拒绝
     * @return /admin/approveaccount
     */
    @RequestMapping("/updateempstatus")
    public String updateempstatus(Integer employeeid,Integer status){
        Integer result = employeeService.updateStatus(employeeid, status);
        return "redirect:/admin/approveaccount";
    }
}
